package com.eight.course.controller;

import com.eight.common.pojo.EduSubject;
import com.eight.common.vo.Result;
import com.eight.course.service.SubjectService;
import com.eight.course.vo.SubjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @program: qy8-education
 * @description:
 * @author: 张亚祥
 * @create: 2023-05-26 19:59
 **/
@RestController
@RequestMapping("core/subject")
@Api("课程列表")
public class SubjectController {
    @Resource
    private SubjectService subjectService;

    @PostMapping("/findsubject/{count}/{pageSize}")
    @ApiModelProperty(value = "课程分类页面")
    public Result findsubject(@PathVariable Integer count, @PathVariable Integer pageSize,@RequestBody SubjectVo subjectVo){
        Result subjectPage = subjectService.findSubjectPage(count, pageSize, subjectVo);
        return Result.success(subjectPage);
    }
    @PostMapping("/changeStatusId")
    @ApiOperation(value = "修改课程分类状态")
    public Result changeStatus(@RequestBody EduSubject eduSubject){
        int status1 = subjectService.updateStatus(eduSubject);
        return Result.success();
    }
    @PostMapping("/insertsubject")
    @ApiOperation(value = "新增课程分类状态")
    public Result insertsubject(@RequestBody EduSubject eduSubject){
        eduSubject.setGmtCreate(LocalDateTime.now());
        eduSubject.setGmtModified(LocalDateTime.now());
        int status1 = subjectService.insertSubject(eduSubject);
        return Result.success();
    }

    @PostMapping("/deletesubject")
    @ApiOperation(value = "单个删除课程分类")
    public Result deletesubject(@RequestBody EduSubject id){
        int i = subjectService.deldeteById(id);
        return  Result.success();
    }
}
